package cnki.util;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;

/**
 * @author: Han
 * @date: 2018/9/29 8:53
 * @dscription: 清洗数据
 */
public class DataWasher {

    public static List<String> washPeriodicalCatalog() {
        BufferedReader reader = null;
        var pSet = new LinkedHashSet<String>();
        try {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream("F:\\periodical1.txt"),
                    StandardCharsets.UTF_8));
            String line;
            while ((line = reader.readLine()) != null) {
                var record = line.split("\t");
                pSet.add(record[0]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                Objects.requireNonNull(reader).close();
            } catch (IOException ignore) {
            }
        }
        return new ArrayList<>(pSet);
    }
}
